﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
using SRM;
using SRM.DataObjects;

public partial class UserControls_EducationQualification_UserControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void rgEducationQualification_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.UpdateCommandName)
        {
            bool hasFilledAllRequiredFields = true;
            GridEditFormItem item = e.Item as GridEditFormItem;
            EducationQualification_ObjectDataSource.UpdateParameters["educationKey"].DefaultValue = SRM.Help.GetHiddenFieldValue(item.FindControl("educationKey"));
            EducationQualification_ObjectDataSource.UpdateParameters["qualification"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("qualification_combobox"));
            EducationQualification_ObjectDataSource.UpdateParameters["discipline"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("discipline_combobox"));
            EducationQualification_ObjectDataSource.UpdateParameters["institution"].DefaultValue = SRM.Help.GetTextBoxValue(item.FindControl("institution_textbox"));
            EducationQualification_ObjectDataSource.UpdateParameters["country"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("country_combobox"));
            EducationQualification_ObjectDataSource.UpdateParameters["durationfrom"].DefaultValue = SRM.Help.GetRadDatePickerValue(item.FindControl("durationfrom_datepicker"));
            EducationQualification_ObjectDataSource.UpdateParameters["durationto"].DefaultValue = SRM.Help.GetRadDatePickerValue(item.FindControl("durationto_datepicker"));
            EducationQualification_ObjectDataSource.UpdateParameters["coursemode"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("coursemode_combobox"));
            EducationQualification_ObjectDataSource.UpdateParameters["educationlevelcodename"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("educationlevelcodename_combobox"));
            EducationQualification_ObjectDataSource.UpdateParameters["classgrade"].DefaultValue = SRM.Help.GetTextBoxValue(item.FindControl("classgrade_textbox"));
            EducationQualification_ObjectDataSource.UpdateParameters["coursename"].DefaultValue = SRM.Help.GetTextBoxValue(item.FindControl("coursename_textbox"));
            EducationQualification_ObjectDataSource.UpdateParameters["certobtaindate"].DefaultValue = SRM.Help.GetRadDatePickerValue(item.FindControl("certobtaindate_datepicker"));
            EducationQualification_ObjectDataSource.UpdateParameters["graduationyear"].DefaultValue = SRM.Help.GetRadNumericTextBoxValue(item.FindControl("graduationyear_datepicker"));
            EducationQualification_ObjectDataSource.UpdateParameters["otherqualification"].DefaultValue = SRM.Help.GetTextBoxValue(item.FindControl("otherqualification_textbox"));
            EducationQualification_ObjectDataSource.UpdateParameters["educationortraining"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("educationortraining_combobox"));
            EducationQualification_ObjectDataSource.UpdateParameters["certification"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("certification_combobox"));
            EducationQualification_ObjectDataSource.UpdateParameters["highesteducation"].DefaultValue = SRM.Help.GetRadioButtonListValue(item.FindControl("highesteducation_radiobuttonlist"));

            // Check to make sure required fields are filled in.
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["educationlevelcodename"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Qualification Level not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["qualification"].DefaultValue)))
            {
                if (EducationQualification_ObjectDataSource.UpdateParameters["educationlevelcodename"].DefaultValue != "30")
                {
                    hasFilledAllRequiredFields = false; // Qualification Obtained not filled
                }
            }
                
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["durationfrom"].DefaultValue)))
                hasFilledAllRequiredFields = false; // DUration From not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["durationto"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Duration To not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["coursemode"].DefaultValue) && (item.FindControl("coursemode_combobox").Visible == true)))
                hasFilledAllRequiredFields = false; // Mode of Study not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["institution"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Institution not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["country"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Country of Study not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["certification"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Country of Study not filled
            if ((hasFilledAllRequiredFields) &&
                (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["certobtaindate"].DefaultValue)) &&
                item.FindControl("certobtaindate_datepicker").Visible)
                hasFilledAllRequiredFields = false; // Cert Obtained Date not filled

            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["graduationyear"].DefaultValue)))
            {
                if (EducationQualification_ObjectDataSource.UpdateParameters["educationlevelcodename"].DefaultValue != "30")
                {
                    hasFilledAllRequiredFields = false; // Graduation Year not filled
                }
            }
                
            
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.UpdateParameters["highesteducation"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Highest Education not filled

            if (hasFilledAllRequiredFields)
            {
                EducationQualification_ObjectDataSource.Update();
            }
            else
            {
                e.Canceled = true;
                System.Web.UI.WebControls.Literal msg = item.FindControl("EducationQualificationMessage") as System.Web.UI.WebControls.Literal;
                if (msg != null)
                {
                    msg.Text = "<p class='warning'>Please fill in required fields.</p>";
                }
            }
            
        }

        if (e.CommandName == RadGrid.DeleteCommandName)
        {
            GridDataItem item = e.Item as GridDataItem;
            EducationQualification_ObjectDataSource.DeleteParameters["educationKey"].DefaultValue = item["EducationKey_column"].Text;
            EducationQualification_ObjectDataSource.Delete();
        }

        if (e.CommandName == RadGrid.PerformInsertCommandName)
        {
            bool hasFilledAllRequiredFields = true;
            GridEditFormInsertItem item = e.Item as GridEditFormInsertItem; // EducationQualification_ObjectDataSource
            EducationQualification_ObjectDataSource.InsertParameters["qualification"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("qualification_combobox"));
            EducationQualification_ObjectDataSource.InsertParameters["discipline"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("discipline_combobox"));
            EducationQualification_ObjectDataSource.InsertParameters["institution"].DefaultValue = SRM.Help.GetTextBoxValue(item.FindControl("institution_textbox"));
            EducationQualification_ObjectDataSource.InsertParameters["country"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("country_combobox"));
            EducationQualification_ObjectDataSource.InsertParameters["durationfrom"].DefaultValue = SRM.Help.GetRadDatePickerValue(item.FindControl("durationfrom_datepicker"));
            EducationQualification_ObjectDataSource.InsertParameters["durationto"].DefaultValue = SRM.Help.GetRadDatePickerValue(item.FindControl("durationto_datepicker"));
            EducationQualification_ObjectDataSource.InsertParameters["coursemode"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("coursemode_combobox"));
            EducationQualification_ObjectDataSource.InsertParameters["educationlevelcodename"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("educationlevelcodename_combobox"));
            EducationQualification_ObjectDataSource.InsertParameters["classgrade"].DefaultValue = SRM.Help.GetTextBoxValue(item.FindControl("classgrade_textbox"));
            EducationQualification_ObjectDataSource.InsertParameters["coursename"].DefaultValue = SRM.Help.GetTextBoxValue(item.FindControl("coursename_textbox"));
            EducationQualification_ObjectDataSource.InsertParameters["certobtaindate"].DefaultValue = SRM.Help.GetRadDatePickerValue(item.FindControl("certobtaindate_datepicker"));
            EducationQualification_ObjectDataSource.InsertParameters["graduationyear"].DefaultValue = SRM.Help.GetRadNumericTextBoxValue(item.FindControl("graduationyear_datepicker"));
            EducationQualification_ObjectDataSource.InsertParameters["otherqualification"].DefaultValue = SRM.Help.GetTextBoxValue(item.FindControl("otherqualification_textbox"));
            EducationQualification_ObjectDataSource.InsertParameters["educationortraining"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("educationortraining_combobox"));
            EducationQualification_ObjectDataSource.InsertParameters["certification"].DefaultValue = SRM.Help.GetRadComboBoxValue(item.FindControl("certification_combobox"));
            EducationQualification_ObjectDataSource.InsertParameters["highesteducation"].DefaultValue = SRM.Help.GetRadioButtonListValue(item.FindControl("highesteducation_radiobuttonlist"));

            // Check to make sure required fields are filled in.
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["educationlevelcodename"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Qualification Level not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["qualification"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Qualification Obtained not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["durationfrom"].DefaultValue)))
                hasFilledAllRequiredFields = false; // DUration From not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["durationto"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Duration To not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["coursemode"].DefaultValue) && (item.FindControl("coursemode_combobox").Visible==true)))
                hasFilledAllRequiredFields = false; // Mode of Study not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["institution"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Institution not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["country"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Country of Study not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["certification"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Country of Study not filled


            if ((hasFilledAllRequiredFields) && 
                (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["certobtaindate"].DefaultValue)) &&
                item.FindControl("certobtaindate_datepicker").Visible)
                hasFilledAllRequiredFields = false; // Cert Obtained Date not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["graduationyear"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Graduation Year not filled
            if ((hasFilledAllRequiredFields) && (string.IsNullOrEmpty(EducationQualification_ObjectDataSource.InsertParameters["highesteducation"].DefaultValue)))
                hasFilledAllRequiredFields = false; // Highest Education not filled

            if (hasFilledAllRequiredFields)
            {
                EducationQualification_ObjectDataSource.Insert();
            }
            else
            {
                e.Canceled = true;
                System.Web.UI.WebControls.Literal msg = item.FindControl("EducationQualificationMessage") as System.Web.UI.WebControls.Literal;
                if (msg != null)
                {
                    msg.Text = "<p class='warning'>Please fill in required fields.</p>";
                }
            }
        }
    }
    
    protected void rgEducationQualification_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            DataTable dt = null;
            GridEditFormItem geiEditedItem = e.Item as GridEditFormItem;
            geiEditedItem.Visible = true;

            // Declare control variables
            Telerik.Web.UI.RadComboBox educationlevelcodename_combobox = null;
            Telerik.Web.UI.RadComboBox educationortraining_combobox = null;
            Telerik.Web.UI.RadComboBox qualification_combobox = null;
            System.Web.UI.WebControls.TextBox otherqualification_textbox = null;
            Telerik.Web.UI.RadDatePicker durationfrom_datepicker = null;
            Telerik.Web.UI.RadDatePicker durationto_datepicker = null;
            Telerik.Web.UI.RadComboBox discipline_combobox = null;
            Telerik.Web.UI.RadComboBox coursemode_combobox = null;
            Telerik.Web.UI.RadComboBox certification_combobox = null;
            System.Web.UI.WebControls.TextBox institution_textbox = null;
            Telerik.Web.UI.RadComboBox country_combobox = null;
            System.Web.UI.WebControls.TextBox classgrade_textbox = null;
            System.Web.UI.WebControls.TextBox coursename_textbox = null;
            Telerik.Web.UI.RadDatePicker certobtaindate_datepicker = null;
            Telerik.Web.UI.RadNumericTextBox graduationyear_datepicker = null;
            System.Web.UI.WebControls.CheckBox highesteducation_checkbox = null;
            System.Web.UI.WebControls.RadioButtonList highesteducation_radiobuttonlist = null;
            

            // Find and Assign control variables
            educationlevelcodename_combobox = geiEditedItem.FindControl("educationlevelcodename_combobox") as Telerik.Web.UI.RadComboBox;
            educationortraining_combobox = geiEditedItem.FindControl("educationortraining_combobox") as Telerik.Web.UI.RadComboBox;
            qualification_combobox = geiEditedItem.FindControl("qualification_combobox") as Telerik.Web.UI.RadComboBox;
            otherqualification_textbox = geiEditedItem.FindControl("otherqualification_textbox") as System.Web.UI.WebControls.TextBox;
            durationfrom_datepicker = geiEditedItem.FindControl("durationfrom_datepicker") as Telerik.Web.UI.RadDatePicker;
            durationto_datepicker = geiEditedItem.FindControl("durationto_datepicker") as Telerik.Web.UI.RadDatePicker;
            discipline_combobox = geiEditedItem.FindControl("discipline_combobox") as Telerik.Web.UI.RadComboBox;
            coursemode_combobox = geiEditedItem.FindControl("coursemode_combobox") as Telerik.Web.UI.RadComboBox;
            institution_textbox = geiEditedItem.FindControl("institution_textbox") as System.Web.UI.WebControls.TextBox;
            country_combobox = geiEditedItem.FindControl("country_combobox") as Telerik.Web.UI.RadComboBox;
            certification_combobox = geiEditedItem.FindControl("certification_combobox") as Telerik.Web.UI.RadComboBox;
            classgrade_textbox = geiEditedItem.FindControl("classgrade_textbox") as System.Web.UI.WebControls.TextBox;
            coursename_textbox = geiEditedItem.FindControl("coursename_textbox") as System.Web.UI.WebControls.TextBox;
            certobtaindate_datepicker = geiEditedItem.FindControl("certobtaindate_datepicker") as Telerik.Web.UI.RadDatePicker;
            graduationyear_datepicker = geiEditedItem.FindControl("graduationyear_datepicker") as Telerik.Web.UI.RadNumericTextBox;
            highesteducation_checkbox = geiEditedItem.FindControl("highesteducation_checkbox") as System.Web.UI.WebControls.CheckBox;
            highesteducation_radiobuttonlist = geiEditedItem.FindControl("highesteducation_radiobuttonlist") as System.Web.UI.WebControls.RadioButtonList;
            System.Web.UI.HtmlControls.HtmlGenericControl modeOfStudyLabel = geiEditedItem.FindControl("modeOfStudyLabel") as System.Web.UI.HtmlControls.HtmlGenericControl;
            System.Web.UI.HtmlControls.HtmlGenericControl certObtainedDateLabel = geiEditedItem.FindControl("certObtainedDateLabel") as System.Web.UI.HtmlControls.HtmlGenericControl;
            System.Web.UI.HtmlControls.HtmlGenericControl majorSpecializationLabel = geiEditedItem.FindControl("majorSpecializationLabel") as System.Web.UI.HtmlControls.HtmlGenericControl;
            System.Web.UI.HtmlControls.HtmlGenericControl certobtaindate_entryhint = geiEditedItem.FindControl("certobtaindate_entryhint") as System.Web.UI.HtmlControls.HtmlGenericControl;
            System.Web.UI.HtmlControls.HtmlGenericControl qualification_combobox_star =
                geiEditedItem.FindControl("qualification_combobox_star") as System.Web.UI.HtmlControls.HtmlGenericControl;
            System.Web.UI.HtmlControls.HtmlGenericControl graduationyear_datepicker_star =
                geiEditedItem.FindControl("graduationyear_datepicker_star") as System.Web.UI.HtmlControls.HtmlGenericControl;

            // Databind the combo-boxes (if any)
            Help.BindSapCodeToComboBox(educationlevelcodename_combobox, SRM_Code.GetEducationLevel("1"));
            //Help.BindSapCodeToComboBox(educationortraining_combobox, SRM_Code.GetEducationOrTraining("1"));
            Help.BindSapCodeToComboBox(qualification_combobox, SRM_Code.GetQualification("1"));
            Help.BindSapCodeToComboBox(coursemode_combobox, SRM_Code.GetCourseMode("1"));
            Help.BindSapCodeToComboBox(country_combobox, SRM_Code.GetCountry("1"));

            // Assign values to control variables
            if ((e.Item.DataItem != null) && (e.Item.DataItem is DataRowView))
            {
                System.Data.DataRow row = ((DataRowView)e.Item.DataItem).Row;

                //educationlevelcodename_combobox.SelectedValue = row.Field<string>("EducationLevelCodeName");
                //educationortraining_combobox.SelectedValue = row.Field<string>("EducationOrTraining"); ;
                //qualification_combobox.SelectedValue = row.Field<string>("Qualification");
                Help.SetComboBoxSelectedValue(educationlevelcodename_combobox, row.Field<string>("EducationLevelCodeName"));
                if ((educationlevelcodename_combobox.SelectedValue == "005") ||
                    (educationlevelcodename_combobox.SelectedValue == "010") ||
                    (educationlevelcodename_combobox.SelectedValue == "015"))
                {
                    majorSpecializationLabel.Visible = false;
                    discipline_combobox.Visible = false;
                    modeOfStudyLabel.Visible = false;
                    coursemode_combobox.Visible = false;
                    coursemode_combobox.SelectedValue = "F";
                }
                else
                {
                    majorSpecializationLabel.Visible = true;
                    discipline_combobox.Visible = true;
                    modeOfStudyLabel.Visible = true;
                    coursemode_combobox.Visible = true;
                }

                if (educationlevelcodename_combobox.SelectedValue == "30") // if selected value is Certification(SG)
                {
                    certObtainedDateLabel.Visible = true;
                    certobtaindate_datepicker.Visible = true;
                    certobtaindate_entryhint.Visible = true;
                    coursename_textbox.Enabled = true;
                    qualification_combobox_star.Visible = false;
                    graduationyear_datepicker_star.Visible = false;
                }
                else
                {
                    certObtainedDateLabel.Visible = false;
                    certobtaindate_datepicker.Visible = false;
                    certobtaindate_entryhint.Visible = false;
                    coursename_textbox.Enabled = false;
                    qualification_combobox_star.Visible = true;
                    graduationyear_datepicker_star.Visible = true;
                }

                Help.SetComboBoxSelectedValue(qualification_combobox, row.Field<string>("Qualification"));
                if ((row.Field<string>("Qualification") != null) && 
                    (row.Field<string>("Qualification").Equals("OTHERS", StringComparison.InvariantCultureIgnoreCase)))
                {
                    otherqualification_textbox.Text = row.Field<string>("OtherQualification");
                    otherqualification_textbox.Visible = true;
                }

                otherqualification_textbox.Text = row.Field<string>("OtherQualification");
                durationfrom_datepicker.SelectedDate = row.Field<DateTime?>("DurationFrom");
                durationto_datepicker.SelectedDate = row.Field<DateTime?>("DurationTo");

                Help.BindSapCodeToComboBox(discipline_combobox, SRM_Code.GetBranchOfStudy("1", educationlevelcodename_combobox.SelectedValue));
                Help.BindSapCodeToComboBox(certification_combobox, SRM_Code.GetCertificate("1", educationlevelcodename_combobox.SelectedValue));
                Help.SetComboBoxSelectedValue(certification_combobox, row.Field<string>("Certification"));

                Help.SetComboBoxSelectedValue(discipline_combobox, row.Field<string>("Discipline"));
                Help.SetComboBoxSelectedValue(coursemode_combobox, row.Field<string>("CourseMode"));
                Help.SetComboBoxSelectedValue(country_combobox, row.Field<string>("Country"));

                institution_textbox.Text = row.Field<string>("Institution");
                coursename_textbox.Text = row.Field<string>("CourseName");
                certobtaindate_datepicker.SelectedDate = row.Field<DateTime?>("CertObtainDate"); ;
                if (row.Field<DateTime?>("GraduationYear").HasValue)
                    graduationyear_datepicker.Value= row.Field<DateTime?>("GraduationYear").Value.Year;
                highesteducation_radiobuttonlist.SelectedValue = row.Field<string>("HighestEducation");

            }
        }
    }
    
    protected void qualification_combobox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {

        System.Web.UI.WebControls.TextBox otherqualification_textbox =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.Controls[1].FindControl("otherqualification_textbox") as System.Web.UI.WebControls.TextBox;

        if (e.Value == "OTHERS")
        {
            otherqualification_textbox.Text = string.Empty;
            otherqualification_textbox.Visible = true;
        }
        else
        {
            otherqualification_textbox.Text = string.Empty;
            otherqualification_textbox.Visible = false;
        }

    }
    
    protected void educationlevelcodename_combobox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        Telerik.Web.UI.RadComboBox discipline_combobox =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("discipline_combobox") as Telerik.Web.UI.RadComboBox;
        Telerik.Web.UI.RadComboBox certification_combobox =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("certification_combobox") as Telerik.Web.UI.RadComboBox;
        Telerik.Web.UI.RadComboBox coursemode_combobox =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("coursemode_combobox") as Telerik.Web.UI.RadComboBox;
        System.Web.UI.WebControls.TextBox coursename_textbox =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("coursename_textbox") as System.Web.UI.WebControls.TextBox;
        System.Web.UI.HtmlControls.HtmlGenericControl modeOfStudyLabel =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("modeOfStudyLabel") as System.Web.UI.HtmlControls.HtmlGenericControl;
        System.Web.UI.HtmlControls.HtmlGenericControl certObtainedDateLabel =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("certObtainedDateLabel") as System.Web.UI.HtmlControls.HtmlGenericControl;
        Telerik.Web.UI.RadDatePicker certobtaindate_datepicker = 
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("certobtaindate_datepicker") as Telerik.Web.UI.RadDatePicker;
        System.Web.UI.HtmlControls.HtmlGenericControl majorSpecializationLabel =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("majorSpecializationLabel") as System.Web.UI.HtmlControls.HtmlGenericControl;
        System.Web.UI.HtmlControls.HtmlGenericControl certobtaindate_entryhint =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("certobtaindate_entryhint") as System.Web.UI.HtmlControls.HtmlGenericControl;
        System.Web.UI.HtmlControls.HtmlGenericControl qualification_combobox_star = 
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("qualification_combobox_star") as System.Web.UI.HtmlControls.HtmlGenericControl;
        System.Web.UI.HtmlControls.HtmlGenericControl graduationyear_datepicker_star =
            ((Telerik.Web.UI.RadComboBox)o).NamingContainer.FindControl("graduationyear_datepicker_star") as System.Web.UI.HtmlControls.HtmlGenericControl;


        if (e.Value == "30")
            coursename_textbox.Enabled = true;
        else
            coursename_textbox.Enabled = false;

        if ((e.Value == "05") ||
            (e.Value == "10") ||
            (e.Value == "15"))
        {
            majorSpecializationLabel.Visible = false;
            discipline_combobox.Visible = false;
            coursemode_combobox.Visible = false;
            modeOfStudyLabel.Visible = false;
        }
        else
        {
            majorSpecializationLabel.Visible = true;
            discipline_combobox.Visible = true;
            coursemode_combobox.Visible = true;
            modeOfStudyLabel.Visible = true;
        }

        if (e.Value == "30") // if selected value is Certification(SG)
        {
            certObtainedDateLabel.Visible = true;
            certobtaindate_datepicker.Visible = true;
            certobtaindate_entryhint.Visible = true;
            qualification_combobox_star.Visible = false;
            graduationyear_datepicker_star.Visible = false;
        }
        else
        {
            certObtainedDateLabel.Visible = false;
            certobtaindate_datepicker.Visible = false;
            certobtaindate_entryhint.Visible = false;
            qualification_combobox_star.Visible = true;
            graduationyear_datepicker_star.Visible = true;
        }

        Help.BindSapCodeToComboBox(discipline_combobox, SRM_Code.GetBranchOfStudy("1", e.Value));
        Help.BindSapCodeToComboBox(certification_combobox, SRM_Code.GetCertificate("1", e.Value));
    }
}